//
//  AboutVC.swift
//  Employee
//
//  Created by swordjoy on 2017/5/10.
//  Copyright © 2017年 remotevillage. All rights reserved.
//

import UIKit

class AboutVC: BaseVC {

  fileprivate var contentView: UIView!
  
  fileprivate var iconImageView: UIImageView!
  fileprivate var nameLabel: UILabel!
  fileprivate var detailLabel: UILabel!
  fileprivate var versionLabel: UILabel!
  fileprivate var copyRightLabel: UILabel!
  
  override func viewDidLoad() {
    super.viewDidLoad()
    create()
  }
  
  override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    
    GlobalConfig.baiduStatisticsPageViewStart("关于")
  }
  
  override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    
    GlobalConfig.baiduStatisticsPageViewEnd("关于")
  }
  
}

// MARK: - fileprivate

extension AboutVC {
  
  fileprivate func create() {
    view.backgroundColor = GlobalConfig.BGWhiteColor
    title = "关于世外物业"
    
    addBackItem()
    
    contentView = UIView()
    view.addSubview(contentView)
    contentView.backgroundColor = UIColor.white
    contentView.snp.makeConstraints { (make) in
      make.left.equalTo(10)
      make.top.equalTo(10)
      make.right.bottom.equalTo(-10)
    }
    contentView.layer.cornerRadius = 4
    contentView.clipsToBounds = true
    
    iconImageView = UIImageView()
    iconImageView.image = UIImage(named: "app_icon")
    contentView.addSubview(iconImageView)
    iconImageView.snp.makeConstraints { (make) in
      make.centerX.equalToSuperview()
      make.width.height.equalTo(75)
      make.top.equalTo(90)
    }
    
    iconImageView.layer.cornerRadius = 7
    iconImageView.clipsToBounds = true
    iconImageView.layer.borderWidth = 0.5
    iconImageView.layer.borderColor = UIColor.hex("#e5e5e5").cgColor
    
    nameLabel = UILabel()
    contentView.addSubview(nameLabel)
    nameLabel.text = SJApp.name
    nameLabel.font = GlobalConfig.bold20Font
    nameLabel.textColor = GlobalConfig.TextDeepColor
    nameLabel.snp.makeConstraints { (make) in
      make.centerX.equalToSuperview()
      make.top.equalTo(iconImageView.snp.bottom).offset(23)
    }
    
    detailLabel = UILabel()
    contentView.addSubview(detailLabel)
    detailLabel.text = "您的物业管理小助手"
    detailLabel.font = GlobalConfig.system14Font
    detailLabel.textColor = GlobalConfig.TextDeepColor
    detailLabel.snp.makeConstraints { (make) in
      make.centerX.equalToSuperview()
      make.top.equalTo(nameLabel.snp.bottom).offset(15)
    }

    versionLabel = UILabel()
    contentView.addSubview(versionLabel)
    versionLabel.text = "V" + SJApp.version
    versionLabel.font = GlobalConfig.system14Font
    versionLabel.textColor = GlobalConfig.TextDeepColor
    versionLabel.snp.makeConstraints { (make) in
      make.centerX.equalToSuperview()
      make.top.equalTo(detailLabel.snp.bottom).offset(12)
    }
    
    copyRightLabel = UILabel()
    contentView.addSubview(copyRightLabel)
    copyRightLabel.text = "©" + "2017" + "-" + "\(Date().inLocalRegion().year)" + " Shiwaixiangcun.com.All Rights Reserved"
    copyRightLabel.font = GlobalConfig.system14Font
    copyRightLabel.textColor = GlobalConfig.TextLightColor
    copyRightLabel.numberOfLines = 0
    copyRightLabel.textAlignment = .center
    
    copyRightLabel.snp.makeConstraints { (make) in
      make.bottom.equalTo(-20)
      make.left.equalTo(10)
      make.right.equalTo(-10)
    }
    
    
  }
  
}
